package com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.repo

import com.lancoo.cpbase.authentication.base.CurrentUser
import com.lancoo.znbkxx.teacher.Ext
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.Constants
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.QuesMarkDeatil
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.QuesMarkInfor
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.remote.BaseData
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.remote.EvalService
import io.reactivex.Single
import okhttp3.RequestBody
import java.util.*

/**
 * Created by Dadong on 2020/9/22
 * Describe:
 */
class EvalRepo constructor(private val remote: EvalService) {
    /*
    * 获取试卷的待评阅试题列表信息
    * */
    fun getPaperForEval(
            paperId: String,
            setId: String
    ): Single<BaseData<QuesMarkInfor>> {
        val params = Constants.createParamas()
        params["PaperID"] = paperId
        params["SetID"] = setId
        return remote.getPaperForEval(params)
    }

    /*
    * (一对一)获取试卷的待评阅试题列表信息
    * */
    fun getPaperForEval_1v1(
            stuId: String,
            paperId: String
    ): Single<BaseData<QuesMarkInfor>> {

        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.getToken()
//        paramas["UserID"] = CurrentUser.getUserID()
//        paramas["SchoolID"] = CurrentUser.getSchoolID()//校内ID
//        paramas["StageNo"] = Ext.STAGE_NO
        paramas["StuID"] = stuId
        paramas["PaperID"] = paperId
        return remote.getPaperForEval_1v1(paramas)
    }

    /*
   * 获取试卷的待评阅试题列表信息
   * */
    fun getQuesForEval(
            setId: String,
            paperId: String,
            quesID: String,
            startIndex: String
    ): Single<BaseData<QuesMarkDeatil>> {
        val params = Constants.createParamas()
        params["setId"] = setId
        params["PaperID"] = paperId
        params["QuesID"] = quesID
        params["StartIndex"] = startIndex
        return remote.getQuesForEval(params)
    }

    /*
 * (一对一)获取试卷的待评阅试题列表信息
 * */
    fun getQuesForEval_1v1(
            stuId: String,
            paperId: String,
            quesID: String,
            startIndex: String
    ): Single<BaseData<QuesMarkDeatil>> {

        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.getToken()
//        paramas["UserID"] = CurrentUser.getUserID()
//        paramas["SchoolID"] = CurrentUser.getSchoolID()//校内ID
//        paramas["StageNo"] = Ext.STAGE_NO
        paramas["StuID"] = stuId
        paramas["PaperID"] = paperId
        paramas["QuesID"] = quesID
        paramas["StartIndex"] = startIndex
        return remote.getQuesForEval_1v1(paramas)
    }

    /*
   * 保存评阅
   * */
    fun savePaperEval(
            evalBody: RequestBody
    ): Single<BaseData<Any>> {
        return remote.savePaperEval(CurrentUser.getToken(), CurrentUser.getUserID(),evalBody)
    }
}